
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>冒泡</title>
</head>
<body>
<script type="text/javascript">


    var arr = [50,97,32,41,32,16,84,46];
    for(var j=0; j<arr.length-1;j++){
        for(var i=0; i<arr.length-1-j;i++){
            if(arr[i]>arr[i+1]){
                var t = arr[i];
                arr[i] = arr[i+1];
                arr[i+1] = t;
            }
        }
    }

    console.log(arr);





</script>

</body>
</html>